package cn.szzsi.business.interceptor;

import cn.szzsi.AConfig;
import cn.szzsi.common.util.SystemConfigUtil;
import cn.szzsi.model.SiteConfig;
import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.jfinal.core.Controller;
import com.jfinal.kit.PropKit;
import com.jfinal.kit.StrKit;

public class CommonInterceptor implements Interceptor {

	public void intercept(Invocation ai) {
	    Controller c = ai.getController();
        c.setAttr("base", c.getRequest().getContextPath());
        c.setAttr("weburl", AConfig.p.get("zshop_web.url"));
        c.setAttr("systemConfig", SystemConfigUtil.getSystemConfig());

        String shopId = c.getPara("shopId");
        if(StrKit.notBlank(shopId)){
            c.setAttr("shopId", shopId);//店铺Id
            SiteConfig siteConfig = SiteConfig.dao.findByShopId(shopId);
            if(siteConfig != null){
                c.setAttr("shopAlias", siteConfig.getStr("shopAlias"));//店铺别名
                c.setAttr("logoUrl",siteConfig.getStr("logoUrl"));//店铺logo
                c.setAttr("siteConfig",siteConfig);
                c.setAttr("shopAlias", siteConfig.getStr("shopAlias"));//店铺别名
                c.setAttr("logoUrl",siteConfig.getStr("logoUrl"));//店铺logo
                c.setAttr("shopName",siteConfig.getStr("shopName"));//店铺名称
                c.setAttr("phone",siteConfig.getStr("phone"));
            }
        }
        ai.invoke();
	}

}
